﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
using BaseTypesLib.Model;

namespace BaseTypesLib.Converters
{
    [ValueConversion(typeof(FieldHorizontalAlignment), typeof(HorizontalAlignment))]
    public class HorizontalAlignmentConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FieldHorizontalAlignment alignment = (FieldHorizontalAlignment)value;
            switch (alignment)
            {
                case FieldHorizontalAlignment.Center: return HorizontalAlignment.Center;
                case FieldHorizontalAlignment.Left: return HorizontalAlignment.Left;
                case FieldHorizontalAlignment.Right: return HorizontalAlignment.Right;
                default: return HorizontalAlignment.Left;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            HorizontalAlignment alignment = (HorizontalAlignment)value;
            switch (alignment)
            {
                case HorizontalAlignment.Center: return FieldHorizontalAlignment.Center;
                case HorizontalAlignment.Left: return FieldHorizontalAlignment.Left;
                case HorizontalAlignment.Right: return FieldHorizontalAlignment.Right;
                default: return FieldHorizontalAlignment.Left;
            }
        }
    }
}
